Skip to content

feat: allow Partitioning::Range to satisfy window Distribution::KeyPartitioned requirements#23416

Draft
mithuncy wants to merge 1 commit into
apache:mainfrom
mithuncy:issue-23289-window-range-on-23184
Draft

feat: allow Partitioning::Range to satisfy window Distribution::KeyPartitioned requirements#23416
mithuncy wants to merge 1 commit into
apache:mainfrom
mithuncy:issue-23289-window-range-on-23184

Conversation

@mithuncy

@mithuncy mithuncy commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rebased on main now that #23184 has merged. Overlaps with #23355, which also opts the window execs into range satisfaction as part of its PartitionedTopK work — happy to rebase whichever lands second.

What changes are included in this PR?

In one commit:

  • Opt WindowAggExec and BoundedWindowAggExec with partition keys into range satisfaction via InputDistributionRequirements::allow_range_satisfaction_for_key_partitioning, mirroring AggregateExec. Compatible range-partitioned inputs then satisfy the window key requirement without a hash repartition; subset satisfaction and the hash fallback for incompatible keys come from the existing satisfaction machinery. Windows without PARTITION BY keep requiring a single partition.

Are these changes tested?

Yes: new slt tests in range_partitioning.slt (exact and subset reuse, rehash on incompatible keys, subset_repartition_threshold / preserve_file_partitions / target_partitions behavior, WindowAggExec via an unbounded frame, and no-PARTITION BY), plus plan-shape tests in enforce_distribution.rs and acceptance/rejection tests in sanity_checker.rs.

Are there any user-facing changes?

No: only plan changes.

@github-actions github-actions Bot added physical-expr Changes to the physical-expr crates optimizer Optimizer rules core Core DataFusion crate sqllogictest SQL Logic Tests (.slt) datasource Changes to the datasource crate physical-plan Changes to the physical-plan crate auto detected api change Auto detected API change labels Jul 9, 2026
@gene-bordegaray

Copy link
Copy Markdown
Contributor

This is in my queue, just waiting for #23184 to land 🙇

@mithuncy mithuncy force-pushed the issue-23289-window-range-on-23184 branch from 3a4b586 to f125c39 Compare July 11, 2026 02:36
@github-actions github-actions Bot removed physical-expr Changes to the physical-expr crates optimizer Optimizer rules datasource Changes to the datasource crate auto detected api change Auto detected API change labels Jul 11, 2026
…rtitioned requirements

Windows got a hash repartition even when the input was already range
partitioned on the PARTITION BY keys. Opt WindowAggExec and
BoundedWindowAggExec into range satisfaction for KeyPartitioned, the
same way AggregateExec does. Incompatible keys still fall back to hash
repartitioning, and windows without PARTITION BY keep requiring a
single partition.

Covered by enforce_distribution and sanity_checker tests plus a window
section in range_partitioning.slt.

Closes apache#23289
@mithuncy mithuncy force-pushed the issue-23289-window-range-on-23184 branch from f125c39 to 2995df1 Compare July 11, 2026 03:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core DataFusion crate physical-plan Changes to the physical-plan crate sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow Partitioning::Range to satisfy window Distribution::KeyPartitioned requirements

2 participants